package servidor.principal;



import java.net.*;
import java.rmi.*;
import servidor.principal.control.*;



public class Servidor {

	private String name = "";
	private String name1="";
	private String name2="";
	private String name3="";
	private String name4="";
	private String name5="";
	private String name6="";
	private String ip = "";

	//Controles
	private ControlCliente controlCliente = null;
	private ControlEmpleado controlEmpleado = null;
	private ControlCategoria controlCategoria = null; 
	private ControlConcepto controlConcepto=null;
	private ControlReciboDeSueldo controlRecibo=null;
	private ControlLibroIva controlLibro=null;
	private ControlComprobante controlComprobante=null;
	private String classPath = "";

	public void iniciar() throws Exception { 

		System.setProperty("java.rmi.server.codebase", "file:" + this.classPath);
		InetAddress host = InetAddress.getLocalHost();

		System.out.println("Iniciando servidor !!!");
		this.ip = host.getHostAddress();
		System.out.println("Ip: " + this.ip);


		this.name = "rmi://" + this.ip + "/IControlCliente";
		this.name1 = "rmi://" + this.ip + "/IControlEmpleado";
		this.name2 = "rmi://" + this.ip + "/IControlCategoria";
		this.name3 = "rmi://" + this.ip + "/IControlConcepto";
		this.name4 = "rmi://" + this.ip + "/IControlReciboDeSueldo";
		this.name5 = "rmi://" + this.ip + "/IControlLibroIva";
		this.name6 = "rmi://" + this.ip + "/IControlComprobante";

		Naming.rebind(this.name, this.controlCliente);
		Naming.rebind(this.name1, this.controlEmpleado);
		Naming.rebind(name2, controlCategoria);
		Naming.rebind(this.name3, this.controlConcepto);
		Naming.rebind(this.name4, this.controlRecibo);
		Naming.rebind(this.name5, this.controlLibro);
		Naming.rebind(this.name6, this.controlComprobante);


		System.out.println("Nombre: " + this.name);

		System.out.println("Servidor OK !!!");

	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setClassPath(String classPath) {
		this.classPath = classPath;
	}

	public void setControlCliente(ControlCliente controlCliente) {
		this.controlCliente = controlCliente;
	}


	public void setControlEmpleado(ControlEmpleado controlEmpleado) {
		this.controlEmpleado = controlEmpleado;

	}
	
	public void setControlCategoria(ControlCategoria controlCategoria) {
		this.controlCategoria = controlCategoria;

	}
	
	public void setControlConcepto(ControlConcepto controlConcepto) {
		this.controlConcepto = controlConcepto;

	}
	
	public void setControlRecibo(ControlReciboDeSueldo controlRecibo) {
		this.controlRecibo = controlRecibo;

	}
	
	public void setControlLibroIva(ControlLibroIva controlLibro) {
		this.controlLibro = controlLibro;

	}
	
	public void setControlComprobante(ControlComprobante controlComprobante) {
		this.controlComprobante = controlComprobante;

	}

}

